%% Functions to plot intervals (given fixed order)

function fig = plot_intervals_fixord(hat_vartheta, bar_tau, predict_se, order)
    
    % Initialization
    N = length(bar_tau);

    % Calculate the recentered intervals
    re_lower_bounds = bar_tau - hat_vartheta - 1.282 * predict_se;
    re_upper_bounds = bar_tau - hat_vartheta + 1.282 * predict_se;
    
    % Sort intervals based on given order
    re_lower_bounds = re_lower_bounds(order);
    re_upper_bounds = re_upper_bounds(order);

    % Prepare the plot
    fig = figure;
    hold on;
    
    for i = 1:N
        % Plot regular bar with pink semi-transparency
        rectangle('Position', [i - 0.4, re_lower_bounds(i), 0.8, re_upper_bounds(i) - re_lower_bounds(i)], ...
                  'FaceColor', [1, 0.6, 0.6, 0.5], 'EdgeColor', 'none'); % Pink
    end

    xtick = 0:2:16;
    xticks(xtick);
    xlim([xtick(1), xtick(end)]);

    ylim([-325 325]);
    % ylim([-400 300]);
    yline(0, 'k--', 'LineWidth', 1);

    % Adjust font size of the x-axis labels
    set(gca, 'FontSize', 18);
   
    hold off;

end
